package com.fs.groupSeven.service.impl;

import com.fs.groupSeven.Dao.ClassDao;
import com.fs.groupSeven.pojo.Class;
import com.fs.groupSeven.service.ClassService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

@Service
public class ClassServiceImpl implements ClassService {

    private ClassDao classDao;

    @Autowired
    public ClassServiceImpl(ClassDao classDao){
        this.classDao = classDao;
    }


    @Override
    public PageInfo<Class> queryclassAll(Integer currentPage, Integer pageSize, Integer collegeId) {
        PageHelper.startPage(currentPage,pageSize);
        List<Class> collegeList = classDao.queryclassAll(collegeId);
        PageInfo<Class> pageInfo = new PageInfo<>(collegeList);
        return pageInfo;
    }

    @Override
    public boolean addTwo(Class clas) {
        int result = classDao.addTow(clas);
        return result>0;
    }

    @Override
    public Class queryclassbyId(Integer classId) {
        Class clas = classDao.queryclassbyId(classId);
        return clas;
    }

    @Override
    public boolean updateOne(Class clas) {
        int result = classDao.updateOne(clas);
        return result>0;
    }

    @Override
    public boolean deleteOne(Integer classId) {
        int result = classDao.deleteOne(classId);
        return result>0;
    }

    @Override
    public Set<Class> getUserThatAddressLike(String classname) {
        return classDao.queryByClassColumn(classname);
    }
}
